package top.yongyan0624.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import top.yongyan0624.mapper.TeacherMapper;
import top.yongyan0624.pojo.Teacher;
import top.yongyan0624.pojo.Teacher;
import top.yongyan0624.service.TeacherService;

import java.util.List;

/**
 * @author Yongyan
 * @description: TODO
 * @date 2020/12/25
 **/

@Service
public class TeacherServiceImpl implements TeacherService {
    @Autowired
    private TeacherMapper teacherMapper;

    public Integer addTeacher(Teacher teacher) {
        return teacherMapper.addTeacher(teacher);
    }

    public Integer deleteTeacher(Integer id) {
        return teacherMapper.deleteTeacher(id);
    }

    public Integer updateTeacher(Teacher teacher) {
        return teacherMapper.updateTeacher(teacher);
    }

    public List<Teacher> findAllTeacher() {
        return teacherMapper.findAllTeacher();
    }

    public PageInfo<Teacher> findAllTeacher(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Teacher> teacherList = teacherMapper.findAllTeacher();

        return new PageInfo<Teacher>(teacherList);
    }

    public Teacher findById(Integer id) {
        return teacherMapper.findById(id);
    }

    public List<Teacher> findByName(String name) {
        return teacherMapper.findByName(name);
    }

    public List<Teacher> findTeacher(Teacher teacher) {
        return teacherMapper.findTeacher(teacher);
    }

    public Integer totalTeacher() {
        return teacherMapper.totalTeacher();
    }
}
